-
The
MGLAnnotationprotocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.An object that adopts this protocol must implement the
See morecoordinateproperty. The other methods of this protocol are optional.Declaration
Objective-C
@protocol MGLAnnotation <NSObject>Swift
protocol MGLAnnotation : NSObjectProtocol
-
The
See moreMGLAnnotationImageclass is responsible for presenting point-based annotations visually on anMGLMapViewinstance. Annotation image objects pairNSImageobjects with annotation-related metadata. They may be recycled later and put into a reuse queue that is maintained by the map view.Declaration
Objective-C
@interface MGLAnnotationImage : NSObject <NSSecureCoding>Swift
class MGLAnnotationImage : NSObject, NSSecureCoding
-
The
MGLOverlayprotocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. Overlays can take the form of a polyline or polygon.You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. This SDK defines several concrete classes that conform to this protocol and define standard shapes.
See moreDeclaration
Objective-C
@protocol MGLOverlay <MGLAnnotation>Swift
protocol MGLOverlay : MGLAnnotation
-
MGLShapeis an abstract class that represents a shape or annotation. Shapes constitute the content of a map – not only the overlays atop the map, but also the content that forms the base map.Create instances of
MGLPointAnnotation,MGLPointCollection,MGLPolyline,MGLMultiPolyline,MGLPolygon,MGLMultiPolygon, orMGLShapeCollectionin order to useMGLShape‘s methods. Do not create instances ofMGLShapedirectly, and do not create your own subclasses of this class. The shape classes correspond to the Geometry object types in the GeoJSON standard, but some have nonstandard names for backwards compatibility.Although you do not create instances of this class directly, you can use its
+[MGLShape shapeWithData:encoding:error:]factory method to create one of the concrete subclasses ofMGLShapenoted above from GeoJSON data.You can add shapes to the map by adding them to an
See moreMGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s shapes collectively using a concrete instance ofMGLVectorStyleLayer. Alternatively, you can add some kinds of shapes directly to a map view as annotations or overlays.Declaration
Objective-C
@interface MGLShape : NSObject <MGLAnnotation, NSSecureCoding>Swift
class MGLShape : NSObject, MGLAnnotation, NSSecureCoding
-
The
MGLMultiPointclass is an abstract superclass used to define shapes composed of multiple vertices.Create instances of
MGLPolylineorMGLPolygonin order to use properties ofMGLMultiPoint. Do not create instances ofMGLMultiPointdirectly and do not create your own subclasses of this class. You can use the method and properties of this class to access information about the vertices of the line or polygon.Do not confuse
See moreMGLMultiPointwithMGLPointCollection, which represents a collection of related but disconnected points.
-
An
MGLPointAnnotationobject represents a one-dimensional shape located at a single geographical coordinate. Depending on how it is used, anMGLPointAnnotationobject is known as a point annotation or point shape. For example, you could use a point shape to represent a city at low zoom levels, an address at high zoom levels, or the location of a long press gesture.You can add point shapes to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s point shapes collectively using anMGLCircleStyleLayerorMGLSymbolStyleLayerobject.For more interactivity, add a selectable point annotation to a map view using the
-[MGLMapView addAnnotation:]method. Alternatively, define your own model class that conforms to theMGLAnnotationprotocol. Configure a point annotation’s appearance using-[MGLMapViewDelegate mapView:imageForAnnotation:]or-[MGLMapViewDelegate mapView:viewForAnnotation:](iOS only). A point annotation’sMGLShape.titleandMGLShape.subtitleproperties define the default content of the annotation’s callout (on iOS) or popover (on macOS).To group multiple related points together in one shape, use an
MGLPointCollectionorMGLShapeCollectionobject.A point shape is known as a Point geometry in GeoJSON.
See more
-
An
MGLPointCollectionobject represents a shape consisting of one or more disconnected vertices, specified asCLLocationCoordinate2Dinstances. The points in the collection may be related but are not connected spatially. For example, you could use a point collection to represent all the trees in an orchard.You can add point collections to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s point collections collectively using anMGLCircleStyleLayerorMGLSymbolStyleLayerobject.You cannot add an
MGLPointCollectionobject directly to a map view as an annotation. However, you can create individualMGLPointAnnotationobjects from thecoordinatesarray and add those annotation objects to the map view using the-[MGLMapView addAnnotations:]method.A point collection is known as a MultiPoint geometry in GeoJSON. Do not confuse
See moreMGLPointCollectionwithMGLMultiPoint, the abstract superclass ofMGLPolylineandMGLPolygon.Declaration
Objective-C
@interface MGLPointCollection : MGLShape <MGLOverlay>Swift
class MGLPointCollection : MGLShape, MGLOverlay
-
An
MGLPolygonobject represents a closed shape consisting of four or more vertices, specified asCLLocationCoordinate2Dinstances, and the edges that connect them. For example, you could use a polygon shape to represent a building, a lake, or an area you want to highlight.You can add polygon shapes to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s polygons collectively using anMGLFillStyleLayerorMGLSymbolStyleLayerobject.Alternatively, you can add a polygon overlay directly to a map view using the
-[MGLMapView addAnnotation:]or-[MGLMapView addOverlay:]method. Configure a polygon overlay’s appearance using-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]and-[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:].The vertices are automatically connected in the order in which you provide them. You should close the polygon by specifying the same
CLLocationCoordinate2Das the first and last vertices; otherwise, the polygon’s fill may not cover the area you expect it to. To avoid filling the space within the shape, give the polygon a transparent fill or use anMGLPolylineobject.A polygon may have one or more interior polygons, or holes, that you specify as
MGLPolygonobjects with the+polygonWithCoordinates:count:interiorPolygons:method. For example, if a polygon represents a lake, it could exclude an island within the lake using an interior polygon. Interior polygons may not themselves have interior polygons. To represent a shape that includes a polygon within a hole or, more generally, to group multiple polygons together in one shape, use anMGLMultiPolygonorMGLShapeCollectionobject.To make the polygon straddle the antimeridian, specify some longitudes less than −180 degrees or greater than 180 degrees.
See moreDeclaration
Objective-C
@interface MGLPolygon : MGLMultiPoint <MGLOverlay>Swift
class MGLPolygon : MGLMultiPoint, MGLOverlay -
An
MGLMultiPolygonobject represents a shape consisting of one or more polygons that do not overlap. For example, you could use a multipolygon shape to represent the body of land that consists of an island surrounded by an atoll: the inner island would be oneMGLPolygonobject, while the surrounding atoll would be another. You could also use a multipolygon shape to represent a group of disconnected but related buildings.You can add multipolygon shapes to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s multipolygons collectively using anMGLFillStyleLayerorMGLSymbolStyleLayerobject.You cannot add an
See moreMGLMultiPolygonobject directly to a map view using-[MGLMapView addAnnotation:]or-[MGLMapView addOverlay:]. However, you can add thepolygonsarray’s items as overlays individually.Declaration
Objective-C
@interface MGLMultiPolygon : MGLShape <MGLOverlay>Swift
class MGLMultiPolygon : MGLShape, MGLOverlay
-
An
MGLPolylineobject represents a shape consisting of two or more vertices, specified asCLLocationCoordinate2Dinstances, and the line segments that connect them. For example, you could use an polyline to represent a road or the path along which something moves.You can add polyline shapes to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s polylines collectively using anMGLLineStyleLayerorMGLSymbolStyleLayerobject.Alternatively, you can add a polyline overlay directly to a map view using the
-[MGLMapView addAnnotation:]or-[MGLMapView addOverlay:]method. Configure a polyline overlay’s appearance using-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]and-[MGLMapViewDelegate mapView:lineWidthForPolylineAnnotation:].The vertices are automatically connected in the order in which you provide them. The first and last vertices are not connected to each other, but you can specify the same
CLLocationCoordinate2Das the first and last vertices in order to close the polyline. To fill the space within the shape, use anMGLPolygonobject. To group multiple polylines together in one shape, use anMGLMultiPolylineorMGLShapeCollectionobject.To make the polyline straddle the antimeridian, specify some longitudes less than −180 degrees or greater than 180 degrees.
A polyline is known as a LineString geometry in GeoJSON.
See moreDeclaration
Objective-C
@interface MGLPolyline : MGLMultiPoint <MGLOverlay>Swift
class MGLPolyline : MGLMultiPoint, MGLOverlay -
An
MGLMultiPolylineobject represents a shape consisting of one or more polylines. For example, you could use a multipolyline shape to represent both sides of a divided highway (dual carriageway), excluding the median (central reservation): each carriageway would be a distinctMGLPolylineobject.You can add multipolyline shapes to the map by adding them to an
MGLShapeSourceobject. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s multipolylines collectively using anMGLLineStyleLayerorMGLSymbolStyleLayerobject.You cannot add an
MGLMultiPolylineobject directly to a map view using-[MGLMapView addAnnotation:]or-[MGLMapView addOverlay:]. However, you can add thepolylinesarray’s items as overlays individually.A multipolyline is known as a MultiLineString geometry in GeoJSON.
See moreDeclaration
Objective-C
@interface MGLMultiPolyline : MGLShape <MGLOverlay>Swift
class MGLMultiPolyline : MGLShape, MGLOverlay
-
An
MGLShapeCollectionobject represents a shape consisting of zero or more distinct but related shapes that are instances ofMGLShape. The constituent shapes can be a mixture of different kinds of shapes.MGLShapeCollectionis most commonly used to add multiple shapes to a singleMGLShapeSource. Configure the appearance of anMGLShapeSource’s orMGLVectorSource’s shape collection collectively using anMGLSymbolStyleLayerobject, or use multiple instances ofMGLCircleStyleLayer,MGLFillStyleLayer, andMGLLineStyleLayerto configure the appearance of each kind of shape inside the collection.You cannot add an
MGLShapeCollectionobject directly to a map view as an annotation. However, you can create individualMGLPointAnnotation,MGLPolyline, andMGLPolygonobjects from theshapesarray and add those annotation objects to the map view using the-[MGLMapView addAnnotations:]method.To represent a collection of point, polyline, or polygon shapes, it may be more convenient to use an
MGLPointCollection,MGLMultiPolyline, orMGLMultiPolygonobject, respectively.A shape collection is known as a GeometryCollection geometry in GeoJSON.
See more
Install in Dash
Shapes and Annotations Reference